import Mock from 'mockjs'

const count = 12
const assessmentBillList = []
const fleetMilesList = []
const plateCountList = []
const plateDetailList = []

const tenant_storage = ['中联物流有限公司', '景德镇物流', '九江物流']
const creator_storage = ['admin', 'liu', 'usw']
const price_storage = [1500, 700, 800, 855]
const price2_storage = [150, 100, 300, 200]
const price3_storage = [45, 72, 86, 64]
const price4_storage = [2, 12, 1, 0]
const brand_storage = ['奥迪', '大众', '江铃']
const payeeName_storage = ['景德镇物流', '魏军车队', '章万里']
const isDelete_storage = ['0', '1']
const endAddr_storage = ['深圳', '武汉', '上海']
const driverMobile_storage = ['13049352355', '13049352356', '13049352357', '13049352359']
const assessItem_storage = ['南江一路', '北江二路']
const fleetName_storage = ['程远车队公司', '陶瓷车队公司', '畅远车队公司']
const totalMiles_storage = [166666, 18833, 32000]
const sendCarPass_storage = ['正常', '风险', '故障']
const type_storage = ['10', '20', '30']
const plate_storage = ['粤B123474', '粤B10122', '粤B123460']

// 支付申请首页 查看详情单所有详情- 考核奖惩账单
for (let i = 0; i < count; i++) {
  assessmentBillList.push(Mock.mock({
    'options1': 'assess-mock20170922' + '@increment',
    'options2': 1536838515000,
    'options3|1': tenant_storage,
    'options4|1': payeeName_storage,
    'options5|1': assessItem_storage,
    'options6|1': brand_storage,
    'options7|1': price2_storage,
    'options8|1': driverMobile_storage,
    'options9|1': creator_storage,
    'options10|1': isDelete_storage,
    'options11|1': endAddr_storage,
    'options12|1': price_storage,
    'options13|1': price2_storage,
    'options14|1': price3_storage,
    'vin|1': driverMobile_storage,
    'gmtCreate': 1536838515000,
    'gmtModify': 1536838515000
  }))
}

for (let i = 0; i < count; i++) {
  fleetMilesList.push(Mock.mock({
    'options1': 'assess-mock20170922' + '@increment',
    'options2': 1536838515000,
    'options3|1': tenant_storage,
    'options4|1': payeeName_storage,
    'options5|1': assessItem_storage,
    'options6|1': brand_storage,
    'options7|1': price2_storage,
    'options8|1': driverMobile_storage,
    'options9|1': creator_storage,
    'sendCarPass|1': sendCarPass_storage,
    'lspName|1': assessItem_storage,
    'mobile|1': driverMobile_storage,
    'totalMiles|1': totalMiles_storage,
    'fleetName|1': fleetName_storage,
    'vin|1': driverMobile_storage,
    'gmtCreate': 1536838515000,
    'gmtModify': 1536838515000
  }))
}

for (let i = 0; i < count; i++) {
  plateCountList.push(Mock.mock({
    'plateLicenseNo|1': plate_storage,
    'normalSum|1': price4_storage,
    'riskSum|1': price4_storage,
    'faultSum|1': price4_storage,
    'gmtCreate': 1536838515000,
    'gmtModify': 1536838515000
  }))
}

for (let i = 0; i < count; i++) {
  plateDetailList.push(Mock.mock({
    'plateLicenseNo|1': plate_storage,
    'type|1': type_storage,
    'sum|1': price4_storage,
    'vehicleSpeed|1': price2_storage,
    'description|1': '',
    'tboxNo|1': 'tboxNo-mock' + '@increment',
    'gmtCreate': 1536838515000,
    'gmtModify': 1536838515000
  }))
}

export default {
  // 统计报表-车牌号详情列表 非分页查询
  getPlateDetailList: config => {
    console.log('mock-getPlateDetailList()-config', config)
    const { type } = JSON.parse(config.body)
    console.log('mock-getPlateDetailList()-type', type)
    const mockList = plateDetailList.filter(item => {
      if (type !== '') {
        if (parseInt(type) === parseInt(item.type)) {
          return true
        } else {
          return false
        }
      }
      return true
    })
    const resData = {
      'code': 0,
      'data': mockList,
      'message': 'mock-success'
    }
    console.log('mock-getPlateDetailList-geList()-resData', resData)
    return resData
  },
  // 统计报表页-车牌号列表 -分页查询
  getPlateCountList: config => {
    // console.log('mock-queryArFundList()-config', config)
    const { current, size, condition } = JSON.parse(config.body)
    const mockList = plateCountList.filter(item => {
      // if (condition !== undefined) {
      //   // if (condition.lspName !== '') return false
      // }
      return true
    })
    const pageList = mockList.filter((item, index) => index < size * current && index >= size * (current - 1))
    // console.log('mock-getPlateCountList-geList()-pageList', pageList)
    const resData = {
      'code': 0,
      'data': {
        'total': mockList.length,
        'size': size,
        'pages': 0,
        'current': current,
        'records': pageList,
        'condition': condition,
        'asc': true,
        orderByField: 'gmt_create',
        'offsetCurrent': 0
      },
      'message': 'mock-success'
    }
    console.log('mock-getPlateCountList-geList()-resData', resData)
    return resData
  },
  // 统计报表 非分页查询
  getTotalFleetMiles: config => {
    console.log('mock-getTotalFleetMiles()-config', config)
    const mockList = fleetMilesList.filter(item => {
      // if (condition !== undefined) {
      //   // if (condition.lspName !== '') return false
      // }
      return true
    })
    const resData = {
      'code': 0,
      'data': mockList,
      'message': 'mock-success'
    }
    console.log('mock-getTotalFleetMiles-geList()-resData', resData)
    return resData
  },
  // 支付申请页-第二步-3.其他扣款(应收账单)
  queryArFundList: config => {
    // console.log('mock-queryArFundList()-config', config)
    const { current, size, condition } = JSON.parse(config.body)
    const mockList = assessmentBillList.filter(item => {
      // if (condition !== undefined) {
      //   // if (condition.lspName !== '') return false
      // }
      return true
    })
    const pageList = mockList.filter((item, index) => index < size * current && index >= size * (current - 1))
    // console.log('mock-queryArFundList-geList()-pageList', pageList)
    const resData = {
      'code': 0,
      'data': {
        'total': mockList.length,
        'size': size,
        'pages': 0,
        'current': current,
        'records': pageList,
        'condition': condition,
        'asc': true,
        orderByField: 'gmt_create',
        'offsetCurrent': 0
      },
      'message': 'mock-success'
    }
    console.log('mock-queryArFundList-geList()-resData', resData)
    return resData
  }
}
